﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Xml;
using System.Data;

using BLL;
using DAL;
using Models;
using Web.Old_App_Code;
using System.Collections;
public partial class cn_member_center_favorites : System.Web.UI.Page
{
    // Fields
    protected FavoritesManager fm = new FavoritesManager();


    // Methods
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["user"] == null)
        {
            base.Response.Redirect("/cn/web_login.html?ru=" + HttpContext.Current.Request.Url.PathAndQuery.Replace("aspx", "html"));
        }
        if (!base.IsPostBack)
        {
            if ((base.Request.QueryString["id"] != null) && this.fm.DeleteFavorites(Convert.ToInt32(base.Request.QueryString["id"])))
            {
                base.Response.Redirect("/cn/member_center/favorites.html");
            }
            this.rptFavoritesBind();
        }
    }

    private void rptFavoritesBind()
    {
        try
        {
            if (this.Session["user"] != null)
            {
                this.rptFavorites.DataSource = this.fm.GetFavoritesByUser((this.Session["user"] as User).Id).DefaultView;
                this.rptFavorites.DataBind();
            }
        }
        catch
        {
        }
    }
}
